<% '------------------------------------- sub kChoice(nChoice,nMax,nTotal,nTotalMax) redim kTemp(nMax) kTemp(0) = 0 if nChoice < nMax then for i = nMax to nChoice+1 step -1 kTemp(i) = i next end if '--------------------------- for i = nChoice to 1 step -1 kCheckChoice =0 do until kCheckChoice = 1 kCheckChoice = 0 kTemp(i) = int(Rnd*(nTotal-0.0000001))+1 if kTemp(i) <= nTotalMax then kCheckChoice=1 for j = nMax to i+1 step -1 if kTemp(i) = kTemp(j) then kCheckChoice = 0 next else kCheckChoice = 0 end if loop next end sub '------------------------------------- %> <% function kData(kLineData,nProbT,nPic) kData = Mid(kLineData,3,Len(kLineData)) k1 = Left(kLineData,1) if k1 = "1" then kData = kData & "

" if k1 = "0" then kData = kData & "
" end function%> <% '------------------------------------------------------------------------------ redim kTemp(500) redim kTempInverse(4) '------------------------------ nProbMaxE = 258 nProbMaxM = 146 nProbMaxH = 39 nProbMax = nProbMaxE + nProbMaxM + nProbMaxH if request.form("textE")<>"" then nProbE= request.form("textE")-1.0 else nProbE=-1.0 if request.form("textM")<>"" then nProbM= request.form("textM")-1.0 else nProbM=-1.0 if request.form("textH")<>"" then nProbH= request.form("textH")-1.0 else nProbH=-1.0 'nProbE = request.form("textE")-1.0 'nProbM=request.form("textM")-1.0 'nProbH = request.form("textH")-1.0 nProbE = nProbE+1.0 nProbM = nProbM+1.0 nProbH = nProbH+1.0 nProb = nProbE + nProbM nProb = nProb + nProbH '-------------------------------------------------- nProbCheck = 0 if (0 <= nProbE) and (nProbE <= nProbMaxE) then nProbCheck = 1 if (0<= nProbM )and (nProbM<= nProbMaxM) then nProbCheck = nProbCheck + 1 if (0<= nProbH) and (nProbH<= nProbMaxH) then nProbCheck = nProbCheck + 1 if nProb > 0 then nProbCheck = nProbCheck+1 RndProblem = request.form("RndProblem") RndChoice = request.form("RndChoice") If RndProblem = "" then RndProblem = 0 If RndChoice = "" then RndChoice = 0 if request.form("back") <>"" then response.redirect("../index.htm") if nProbCheck <> 4 then strHTML = "
" strHTML = strHTML & "How many problems would you like to try?
" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "" strHTML = strHTML & "
Easy: (maximum " & nProbMaxE & ")
Medium: (maximum " & nProbMaxM & ")
Hard: (maximum " & nProbMaxH & ")
" strHTML = strHTML & "Random Problems
" strHTML = strHTML & "Random Choices
" strHTML =strHTML & "" strHTML =strHTML & "
" response.write(strHTML) else kTime = second(time) redim qProb(nProb), qProbT(nProb),qAnswer(nProb) '-------------------------------------------------------------------------------------------------------- call kChoice(RndProblem*nProbE,nProbE,nProbMaxE+kTime,nProbMaxE) for n = 1 to nProbE qProbT(n) = "dataE\" & kTemp(n) next call kChoice(RndProblem*nProbM,nProbM,nProbMaxM+kTime,nProbMaxM) for i = 1 to nProbM qProbT(nProbE+i) = "dataM\" & kTemp(i) next call kChoice(RndProblem*nProbH,nProbH,nProbMaxH+kTime,nProbMaxH) for j = 1 to nProbH qProbT(nProbE+nProbM+j) = "dataH\" & kTemp(j) next '--------------------------------------- call kChoice(RndProblem*nProb,nProb,nProb+kTime,nProb) for n = 1 to nProb qProb(n) = kTemp(n) next '-------------------------------------------------------------------------------------------------------- strHTML = "
" strHTML = strHTML & "" strHTML = strHTML & "" for n = 1 to nProb temp = "" strHTML = strHTML & temp Set fs=Server.CreateObject("Scripting.FileSystemObject") temp = qProbT(qProb(n)) & "\input.txt" Set f=fs.OpenTextFile(Server.MapPath(temp), 1) redim qChoice(4) for i = 0 to 4 qChoice(i) = kData(trim(f.ReadLine),qProbT(qProb(n)),i) next qAnswer(n) = right(trim(f.ReadLine),1) kRandom = right(trim(f.ReadLine),1)+1-1 '---------------------------- Call kChoice(RndChoice*kRandom,4,4+kTime,4) for i = 1 to 4 kTempInverse(kTemp(i)) = i next '---------------------------- strHTML = strHTML & "
Prob "& n &"
" strHTML = strHTML & qChoice(0) for i = 1 to 4 temp = "" strHTML = strHTML & temp temp = "["& i & "] " strHTML = strHTML & temp strHTML = strHTML & qChoice(kTemp(i)) 'strHTML = strHTML & "
" next strHTML = strHTML & "" strHTML = strHTML & "
" f.Close Set f=Nothing Set fs=Nothing next strHTML =strHTML & "" strHTML = strHTML & "
" response.write(strHTML) end if %>